<?php

namespace app\model;


use think\Model;

class TokenModel extends Model
{
    public $name = 'home_token';

    public static function getToken($map=[])
    {
        $token = self::where($map)->whereTime("created_at",60*60*5)->find();
        if (empty($token)) {
            return [];
        }
        return $token;
    }
    public static function setUpdate($map=[],$data=[]){
        $token = self::where($map)->find();
        if (empty($token)){
          return self::inserts($data);
        }
        return self::where($map)->update($data);
    }
}